package com.qxp.simplerpc;

import com.qxp.simplerpc.application.SimpleRpcApplication;
import com.qxp.simplerpc.annotation.EnableSimpleRpcAutoConfig;
import com.qxp.simplerpc.connect.RpcClientInvoker;
import com.qxp.simplerpc.registry.Subscribe;
import com.qxp.simplerpc.connect.RpcClient;
import com.qxp.simplerpc.connect.RpcClientHandler;
import com.qxp.simplerpc.proxy.CglibProxy;
import com.qxp.simplerpc.proxy.CommonProxy;
import com.qxp.simplerpc.proxy.JdkProxy;
import com.qxp.simplerpc.retry.ConnectionListener;
import com.qxp.simplerpc.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnBean(annotation= EnableSimpleRpcAutoConfig.class)
@ConditionalOnProperty(prefix = "spring.simplerpc",value="client")
@AutoConfigureAfter(AutoConfiguration.class)
public class ConsumerAutoConfiguration extends CommonAutoConfiguration {
    @Bean
    public Subscribe getSimpleRpcClient(){
        return new Subscribe();
    }
    @Bean
    public RpcClient getRpcClient(){
        return new RpcClient();
    }
    @Bean
    public RpcClientHandler getRpcClientHandler(){
        return new RpcClientHandler();
    }
    @Bean
    public CommonProxy getCommonProxy(){
        return new CommonProxy();
    }
    @Bean
    public SimpleRpcApplication getSimpleRpcApplication(){
        return new SimpleRpcApplication();
    }
    @Bean
    public ConnectionListener getConnectionListener(){
        return new ConnectionListener();
    }
    @Bean
    public CommonProxy getJdkProxy(){
        return new JdkProxy();
    }
    @Bean
    public CommonProxy getCglibProxy(){
        return new CglibProxy();
    }
    @Bean
    public RpcClientInvoker getRpcClientInvoker(){return new RpcClientInvoker();}


}
